<template>
	<div>
		<el-form
			ref="form"
			:inline="true"
			:model="queryData"
			label-width="100px"
		>
			<el-form-item error>
				<el-input
					v-model.trim="queryData.userName"
					v-symbols
					size="medium"
					:placeholder="$t('common.please_enter')"
					clearable
					style="width: 278px"
				></el-input>
			</el-form-item>
			<el-form-item>
				<el-button
					type="primary"
					icon="el-icon-search"
					size="medium"
					@click="search(queryData)"
				>
					{{ $t('common.search') }}
				</el-button>
				<el-button
					icon="el-icon-refresh-left"
					size="medium"
					@click="reset()"
				>
					{{ $t('common.reset') }}
				</el-button>

			</el-form-item>
		</el-form>
		<TableContainer
			:columns="columns"
			v-bind="tableProps"
		>
		</TableContainer>
	</div>
</template>

<script>
import TableContainer, { manager, initTableProps, TableColumns } from '@/components/TableContainer'
export default {
	components: {
		TableContainer
	},
	data() {
		return {
			show: false,
			queryData: {
				userName: undefined,
				userNameType: '0',
				'timeStart': '2023-04-20 00:00:00',
				'timeEnd': '2023-07-21 23:59:59'
			},
			tableProps: initTableProps(),
			columns: [
				{
					label: this.$t('common.member_number'),
					prop: 'userName'
				},
				{
					label: this.$t('common.components.member_name'),
					prop: 'realName'
				},
				{
					label: this.$t('common.belong_merchant'),
					prop: 'merchantId'
				},
				TableColumns.multiLine({
					label: [this.$t('common.top_agent'), this.$t('common.components.agent_level')],
					prop: ['parentProxyName', 'parentProxyLevel']
				}),
				TableColumns.balance({
					prop: 'balance',
					label: this.$t('member.balance')
				}),
				TableColumns.actions({
					actions: [{
						text: '编辑'
					}]
				}),
				{
					label: this.$t('common.components.member_name'),
					prop: 'realName',
					fixed: 'right'
				}
			]
		}
	},
	mounted() {
		const { reset, fetchApi } = manager({
			api: this.$api.memberListAPI, // 接口地址
			tableProps: this.tableProps, // table props
			defaultParams: this.queryData // 接口参数
		})
		this.search = fetchApi
		this.reset = () => {
			// 必传参数
			const initParams = {
				'timeStart': '2023-04-20 00:00:00',
				'timeEnd': '2023-07-21 23:59:59',
				userNameType: 0
			}
			reset(initParams)
		}
	}
}
</script>

<style scoped lang="scss"></style>
